<template>
	<view class="">
		<u-navbar title="位置信息" :autoBack="true" :placeholder="true"></u-navbar>

		<!-- 地图 -->
		<view class="">
			<map name="" class="map" :latitude="latitude" :longitude="longitude" :markers="covers"></map>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latitude: 39.909,
				longitude: 116.39742,
				covers: [{
					latitude: 39.909,
					longitude: 116.39742,
					iconPath: '../../static/images/other/local.png'
				}], //地图标志位置
			}
		},
		onShow() {
			this.getLocation();
		},
		
		methods:{
			// 获取当前位置
			getLocation() {
				let that = this;
				wx.getLocation({
					type: 'gcj02', //返回可以用于wx.openLocation的经纬度
					success(res) {
						console.log(res);
						that.latitude = res.latitude;
						that.longitude = res.longitude;
						that.covers = [{
							latitude: that.latitude,
							longitude: that.longitude,
							iconPath: '../../static/images/other/local.png'
						}]
					}
				})
			},
		},

	}
</script>

<style scoped>
	.map {
		width: 100%;
		height: 100vh;
	}
</style>